package com.house.api.controller;

import com.house.common.result.Result;
import com.house.model.dto.CollectChangeDto;
import com.house.model.vo.HouseVo;
import com.house.service.service.ICollectService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/collect")
@Api(tags = "收藏相关接口",value = "收藏相关接口")
public class CollectController {

    @Autowired
    private ICollectService collectService;

    @GetMapping("/{houseId}")
    public Result isCollect(@PathVariable("houseId") String houseId) {
        boolean collectByHouseId = collectService.isCollectByHouseId(houseId);
        return Result.ok(collectByHouseId);
    }

    @PostMapping("/change")
    public Result changeCollect(@RequestBody CollectChangeDto dto) {
        collectService.changeCollect(dto);
        return Result.ok();
    }

    @GetMapping("/count")
    public Result getCollectCount(){
        int collectCount = collectService.getCollectCount();
        return Result.ok(collectCount);
    }

    @GetMapping("/list")
    public Result list(){
        List<HouseVo> list = collectService.selectCollectByUserId();
        return Result.ok(list);
    }

}
